package day11;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Map;
import java.util.HashMap;
import java.util.Set;

import java.util.Date;
import java.util.Calendar;

/*

* */
public class DemoDay1011 {
    public static void main(String[] args) throws ParseException {
//        // 1.
//        DemoDay1011 test = new DemoDay1011();
//        test.count("aabbbswacc");
        //2.小明的出生日期是2020年10月28日，请计算小明出生后10000天的日期
        String timeString = "2020-10-28";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date = null;
        try {
            date = sdf.parse(timeString);
            long timeStamp = date.getTime();

            long timeStamps = (24 * 60 * 60 * 1000 * 10000);
            long lastStamp = (timeStamp + timeStamps);


            String dateLast = sdf.format(new Date(lastStamp));
            System.out.println(dateLast);
        } catch (ParseException e) {
            e.printStackTrace();
        }

//        3.

        Calendar calendar = Calendar.getInstance();


        calendar.setTimeInMillis(date.getTime());


        int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);

        switch (dayOfWeek) {
            case Calendar.SUNDAY:
                System.out.println("星期日");
                break;
            case Calendar.MONDAY:
                System.out.println("星期一");
                break;
            case Calendar.TUESDAY:
                System.out.println("星期二");
                break;
            case Calendar.WEDNESDAY:
                System.out.println("星期三");
                break;
            case Calendar.THURSDAY:
                System.out.println("星期四");
                break;
            case Calendar.FRIDAY:
                System.out.println("星期五");
                break;
            case Calendar.SATURDAY:
                System.out.println("星期六");
                break;
            default:
                System.out.println("日期错误");
                break;
        }

    }
//    1.将一个字符串转化为字符和出现次数,比如 aabbbswacc 转化为 a3b3c2s1w1
    private Map<Character, Integer> countMap = new HashMap<Character, Integer>();

    public void count(String str) {
        char[] chars = str.toCharArray();

        for (char ch : chars) {

            if (!countMap.containsKey(ch)) {

                countMap.put(ch, 0);
            }

            int count = countMap.get(ch);
            countMap.put(ch, count + 1);
        }
     
        Set<Character> keys = countMap.keySet();
        for(Character ch : keys){
            System.out.print(ch);
            System.out.print(countMap.get(ch));
        }

    }


}
